﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _027
{
    //父类
    class Shape
    {
        protected int width, height;//只能在父类、子类中使用
        public void setWidth(int w)
        {
            width = w;
        }
        public void setHeight(int h)
        {
            height = h;
        }
    }
    //子类
    class Rectangle:Shape
    {
        public int getArea()
        {
            return width * height;
        }
    }
    internal class Program
    {
        static void Main(string[] args)
        {
            Rectangle oblong = new Rectangle();
            oblong.setWidth(3);
            oblong.setHeight(4);
            int area = oblong.getArea();
            Console.WriteLine("长方形的面积为：{0}",area);

            Test.str = "C#编程网站";
            Console.WriteLine(Test.str);Test test1 = new Test();
            test1.getStr();

            Test test2 = new Test();
            test2.getStr();
            test2.setStr("Http://");
            test1.getStr();
            test2.getStr();
            Console.ReadKey();

        }
    }
    public class Test
    {
        public static string str;
        public void setStr(string a)
        {
            str = a;
        }
        public void getStr()
        {
            Console.WriteLine(str);
        }
    }
}
